		<div class="ibox float-e-margins">
			<div class="ibox-title" style="border: none;">
				<h5 style="color: #00afef"><i>Add</i></h5>
				<div id="form-add-btn" class="ibox-tools">
					<button class="btn btn-sm btn-primary save-btn-tab" id="saveForm">Save</button>
					<button class="btn btn-sm btn-primary btn-outline close-add cancel-btn-tab">Cancel</button>
				</div>
			</div>
			<div class="ibox-content">
			<form class="form-horizontal" id="form-forms">
					<div class="form-group">
						<label class="col-lg-4 control-label">Code</label>
						<input type="hidden" name="form-id">
						<div class="col-lg-3">
							<input name="form-code" type="text" class="form-control">
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-4 control-label">Name</label>
						<div class="col-lg-5">
							<input type="text" name="form-name" class="form-control">
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-4 control-label">Description</label>
						<div class="col-lg-5">
							<input type="text" name="form-desc" class="form-control">
						</div>
					</div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">Program Type</label>
                        <div class="col-lg-5">
                            <select class="form-control m-b" name="prog_type" id ="prog_type">
                                <option value="" id="empty-option">--</option>
                                <?php foreach($prog_type as $p): ?>
                                <option value="<?php echo $p->lookup_code; ?>"><?php echo $p->meaning; ?></option>
                                <?php endforeach ?>
                            </select>
                        </div>
                    </div>
					<div class="form-group">
						<label class="col-lg-4 control-label">Module</label>
						<div class="col-lg-5">
							<select class="form-control m-b" name="module-id" id ="module_option">
                                <option value="" id="empty-option">Select Module</option>
                                <?php foreach ($mods as $m) {?>
                                <option value ="<?php echo $m->module_id; ?>"><?php echo $m->module_name; ?></option>
                                <?php } ?>
                            </select>
						</div>
					</div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">Module Menu</label>
                        <div class="col-lg-5">
                            <select class="form-control m-b" name="mod_menu_id" id ="module_menu_option">
                                <option value="" id="empty-option">Select Module Menu</option>
                                <option value="-1">None</option>
                                <?php //foreach($modulemenu as $mm) { ?>
                                <!--<option value ="<?php echo $mm->menu_id; ?>"><?php echo $mm->menu_name; ?></option>-->
                                <?php //} ?>
                            </select>
                        </div>
                    </div>
                    <!-- <div class="form-inline form-group" id="exe-file-add">
                        <label class="col-sm-4 control-label">Executable Filename</label>
                         <div class="col-lg-5">
                            <input type="file" class="filestyle" data-icon="false" id="upfile" data-buttonText="Browse" data-buttonName="btn-primary">
                            <input type="hidden" name="form-exe-name" id="hiddenExe">
                        </div>
                    </div> -->
					<div class="form-group">
						<label class="col-lg-4 control-label">Executable Filename</label>
						<div class="col-lg-5">
							<input type="text" name="form-exe-name" class="form-control">
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-4 control-label">Enable</label>
						<div class="col-lg-1">
							<input checked type="checkbox" class="i-checks" value="ok" name="form-enabler" >
						</div>
					</div>
					</form>
				</div>
			</div>
		</div>
	</div>

	<script type="text/javascript">
            $(document).ready(function() {
                $('select').chosen({width: '100%'});
                $("#upfile").filestyle({buttonName: "btn-primary"},{icon: false});
            	$('.i-checks').iCheck({
		            checkboxClass: 'icheckbox_square-green',
		            radioClass: 'iradio_square-green'
		        });

                $('#module_option').change(function(){
                    var id = $('#module_option').val();
                    console.log(id);
                    $.ajax({
                    type: "POST",
                    url: "<?php echo base_url($this->session->userdata('forajax') . '/searchmodmenu'); ?>",
                    data: { "mod_menu_id" : id },
                    dataType: 'json',
                    success: function(e){
                        console.log(e);
                        var tmp = "";
                        $.each(e, function(i, item) {
                            tmp += "<option value='"+e[i].menu_id+"'>"+e[i].menu_name+"</option>";
                        });
                        tmp = tmp + "<option value='-1'>None</option>";
                        $('#module_menu_option').html(tmp);
                        $('select').trigger('chosen:updated');
                    }
                    });
                });

                $('#saveForm').click(function(){
                        $.ajax({
                            url: "<?php echo base_url($this->session->userdata('forajax') . '/saveForm'); ?>",
                            method:'post',
                            data:$('#form-forms').serialize(),
                            dataType:'json',
                            success: function (data) {
                                var text = data.msg;
                                var term = "exists";
                                console.log(text);
                                if(data.msg === "<p>You did not select a file to upload.</p>" || data.msg === "<p>The filetype you are attempting to upload is not allowed.</p>"){
                                    notifymsg('danger','<b>Error:</b> '+data.msg);
                                }else if(text === null){
                                        $('#add-link').remove();
                                        $('#add').remove();
                                        $('#tab-list a:first').tab('show');
                                        $('#count_add').val('0');
                                        notifymsg('success','<b>Success</b>: Data saved.');
                                }else if(text.indexOf(term) !== -1){
                                        $('#err-msg').html(data.msg);
                                        notifymsg('danger','<b>Error</b>: '+data.msg);
                                }else{

                                }
                            },
                            complete: function() {
                                $("#saveForm").removeAttr("disabled");
                            },
                            beforeSend: function(){
                                $("#saveForm").attr("disabled", true);
                            }
                        });

                });

                // $('#saveForm').click(function(){
                //         $('#notify-err').hide();
                //         $('#notify-suc').hide();
                //         console.log('save form!');
                //         var filename = $('#upfile').val()

                //         if(filename.match(/fakepath/)) {
                //                 filename = $('#upfile').val().split("\\");
                //                 $('#hiddenExe').val(filename[2]);
                //         }
                //         else{
                //                  $('#hiddenExe').val(filename);
                //         }
                //         var form = new FormData(document.getElementById('form-forms'));
                //         var file = document.getElementById('upfile').files[0];
                //             if (file) {
                //         form.append('upfile', file);
                //         }

                //         var allFilled = true;
                //         $('#form-forms :input:not(:button,:hidden,:checkbox,:file)' ).each(function(index, element) {
                //             if (element.value === '') {
                //                 allFilled = false;
                //             }
                //         });
                //         if($('#module_option select').val() == ''){
                //             allFilled = false;
                //         }
                //         if($('#menu_module_option select').val() == ''){
                //             allFilled = false;
                //         }
                //         if($('#prog_type select').val() == ''){
                //             allFilled = false;
                //         }
                //         if(allFilled == true){
                //             $.ajax({
                //                 url: "<?php echo base_url('submit-form'); ?>",
                //                 method: 'post',
                //                 mimeType: "multipart/form-data",
                //                 contentType: false, //must, tell jQuery not to process the data
                //                 processData: false, //must, tell jQuery not to set contentType//data:{"pcode":code,"pname":name,"desc":desc,"modID":midf,"ppGroup":plst,"upfile":'watchupakii',"pType":ptyp,"enabled":ena},
                //                 data:form,
                //                 dataType:'json',
                //                 success: function (data) {
                //                     var text = data.msg ;
                //                     var term = "exists";
                //                     console.log(text);
                //                     if(data.msg === "<p>You did not select a file to upload.</p>" || data.msg === "<p>The filetype you are attempting to upload is not allowed.</p>"){
                //                         notifymsg('danger','<b>Error:</b> '+data.msg);
                //                     }else if(text === null){
                //                             counter = 1;
                //                             $('#add-link').remove();
                //                             $('#add').remove();
                //                             $('#tab-list a:first').tab('show');
                //                             $('#count_add').val('0');
                //                             notifymsg('success','<b>Success</b>: Data saved.');
                //                     }else if(text.indexOf(term) !== -1){
                //                             $('#err-msg').html(data.msg);
                //                             notifymsg('danger','<b>Error</b>: '+data.msg);
                //                     }else{

                //                     }
                //                 },
                //                 complete: function() {
                //                     $("#saveForm").removeAttr("disabled");
                //                 },
                //                 beforeSend: function(){
                //                     $("#saveForm").attr("disabled", true);
                //                 }
                //             });
                //         }else{
                //                 notifymsg('danger','<b>Error</b>: Some Fields are Empty.');
                //         }

                // });

           });

	</script>